home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls011.1.Z / tls011.1 / usr / mmdf / table / tools / mmdfalias next >
Encoding:
Text File  |  1991-10-25  |  2.2 KB  |  102 lines

  1. :
  2. #
  3. #    @(#)mmdfalias    23.2 90/11/22 SCOCAN
  4. #
  5. #    Copyright (C) The Santa Cruz Operation, Inc., 1989.
  6. #    This Module contains Proprietary Information of
  7. #    The Santa Cruz Operation, Inc., and is Confidential.
  8. #
  9. # mmdfalias - convert old-style aliases files to MMDF format.
  10. #
  11. PATH=/bin:/usr/bin:/usr/sco/bin
  12. export PATH
  13.  
  14. #
  15. # Configuration parameters.
  16. #
  17. ALIASFILE=/usr/lib/mail/aliases
  18. TMPFILE=/tmp/mmalias$$
  19. DESTDIR="."
  20.  
  21. trap "rm -f $TMPFILE; exit 1" 1 2 3 15
  22. cd $DESTDIR
  23.  
  24. #
  25. # Convert the aliases file to MMDF format.
  26. #
  27. # The sed command does:
  28. #
  29. # Remove lines with $e
  30. # '/$e/d'
  31. #
  32. # Remove quoted $n entries and their ilk,
  33. # first for entries that end with
  34. # a comma, then for those that don't.
  35. #
  36. # 's/ *"$[nxpr] .*",//'
  37. # 's/ *"$[nxpr] .*"//'
  38. #
  39. # Remove unqoted $n entries.
  40. #
  41. # 's/ *$[nxpr][^     ]*,//'
  42. # 's/ *$[nxpr][^     ]*//'
  43. #
  44. # Map machine?user to user@machine, first for quoted entries,
  45. # then for unquoted.
  46. #
  47. # 's/\([^     :]*\)\?\("[^     ]*\")/\2@\1/g'
  48. # 's/\([^     :]*\)\?\([^     ,]*\)/\2@\1/g'
  49. #
  50. # Convert "user@sco" to "user@sco.sco.COM" because sco
  51. # is considered local by all hosts.
  52. #
  53. # 's/@sco,/@sco.sco.COM,/g' \
  54. # 's/@sco$/@sco.sco.COM/g' \
  55. #
  56. # "| cat >> file" doesn't work, so make it
  57. # "network/file"
  58. #
  59. # 's%\|[     ]*cat[     ]*>>[     ]*%network\/%g' \
  60. #
  61. # Make all pipes run as network.
  62. #
  63. # 's/\|/network\|/g'
  64. #
  65. # Append a '\' to the end of lines that are continued.
  66. #
  67. # 's/\([:,]\) *$/\1 \\/'
  68. #
  69. # It's ugly, I know, but sed's like that.  You can't even
  70. # put comments in-line, which is why they're up here.
  71. #
  72. sed \
  73.     -e '/$e/d' \
  74.     -e 's/ *"$[nxpr].*",//' \
  75.     -e 's/ *"$[nxpr].*"//' \
  76.     -e 's/ *$[nxpr][^     ]*,//' \
  77.     -e 's/ *$[nxpr][^     ]*//' \
  78.     -e 's/\([^     :]*\)\?\("[^     ]*\")/\2@\1/g' \
  79.     -e 's/\([^     :]*\)\?\([^     ,]*\)/\2@\1/g' \
  80.     -e 's/@sco,/@sco.sco.COM,/g' \
  81.     -e 's/@sco$/@sco.sco.COM/g' \
  82.     -e 's%\|[     ]*cat[     ]*>>[     ]*%network\/%g' \
  83.     -e 's/\|/network\|/g' \
  84.     -e 's/\([:,]\) *$/\1 \\/' \
  85.     $ALIASFILE > $TMPFILE
  86.  
  87. #
  88. # Split into two files, one with list-type aliases, the
  89. # other with user-to-machine mapping.
  90. #
  91. csplit -s $TMPFILE "/user to machine mapping/"
  92.  
  93. mv -f alias.list alias.list-
  94. mv -f alias.user alias.user-
  95.  
  96. mv xx00 alias.list
  97. mv xx01 alias.user
  98.  
  99. ./dbmbuild
  100.  
  101. rm -f $TMPFILE
  102.